/*
 * Copyright 2007-2008 by Matthias Buch-Kromann <mbk.isv@cbs.dk>.
 * 
 * This file is part of the Open-source Dependency Toolkit (OSDT),
 * see http://code.google.com/p/open-source-dependency-toolkit. 
 * 
 * The OSDT is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published
 * by the Free Software Foundation, either version 3 of the License,
 * or (at your option) any later version.
 *
 * The OSDT is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with the OSDT in the file COPYING and COPYING.LESSER. If not, see
 * http://www.gnu.org/licenses.
 */


package org.osdtsystem.values;

/**
 * A feature name. Feature names that start with "#" are reserved for internal
 * features, ie, features that are used by the OSDT software to hold internal
 * variables. 
 * @author Matthias Buch-Kromann <mbk.isv@cbs.dk>
 */
public final class StringFeature extends AbstractFeature implements Feature {
    private String string;

    public StringFeature(String s) {
        string = s;
    }
    
    @Override
    public boolean internalFeature() {
        return string.startsWith("#");
    }
    
    /**
     * Return the feature name as a string.
     * @return 
     */
    @Override
    public String toString() {
        return string;
    }

    @Override
    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        final StringFeature other = (StringFeature) obj;
        if (this.string != other.string 
                && (this.string == null || !this.string.equals(other.string))) {
            return false;
        }
        return true;
    }

    @Override
    public int hashCode() {
        int hash = 5;
        hash = 31 * hash + (this.string != null ? this.string.hashCode() : 0);
        return hash;
    }
}
